import greenfoot.*;  
import java.awt.Font;
import java.awt.Color;

/**
 * Generic Label control used thru entire game
 * 
 * @author Jasper Jans
 * 
 */
public class Label extends Actor
{
    private World world;
    private int yPosition, xPosition;
    private String text;
    private int textSize = 25;
    private Color foreColor = Color.WHITE;

    public void setTextSize(int textSize)
    {
        this.textSize = textSize;
    }
    
    public int getTextSize()
    {
        return this.textSize;
    }
    
    public void setForeColor(Color color)
    {
        this.foreColor = color;
    }
    
    public Color getForeColor()
    {
        return this.foreColor;
    }
    
    public Label()
    {
    }
    
    public Label(World world, int xPosition, int yPosition)
    {
        this.world = world;
        this.text = "[text not set]";
        this.xPosition = xPosition;
        this.yPosition = yPosition;
        
        world.addObject(this, this.xPosition, this.yPosition);
    }
   
    public void setYPosition(int yPosition)
    {
        this.yPosition = yPosition;
    }
    
    public int getYPosition()
    {
        return this.yPosition;
    }
    
    public void setXPosition(int xPosition)
    {
        this.xPosition = xPosition;
    }
    
    public int getXPosition()
    {
        return this.xPosition;
    }
    
    public String getText()
    {
        return text;
    }
    
    public void setText(String text)
    {
        this.text = text;
        renderLabel();
    }
    
    public void setText(String text, int textSize)
    {
        setTextSize(textSize);
        setText(text);
    }
    
    public void renderLabel()
    {
        if(text == "") return ;
        
        GreenfootImage image = new GreenfootImage(text, textSize, foreColor, null);
        setLocation(xPosition + (image.getWidth() / 2), yPosition + (image.getHeight() / 2));
        setImage(image);
    }
}
